#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <pthread.h>
#include "Service.h"
#include "Log.h"
#include "kisql.h"

pthread_t pthread_socket;
pthread_t pthread_logic;
pthread_t pthread_kisql;
string TAG="Service";


void *pthread_socket_cb(void *arg)
{
    Service *service = new Service();
    service->init();
    service->start();
    service->stop();
    return NULL;
}

void *pthread_kisql_cb(void *arg)
{
    kisql *db = kisql::getInstance();
    std::cout << "init kisql" << "\n";
    db->initDB("localhost", "xkx", "root", "xkx");
    return NULL;
}

void *pthread_logic_cb(void *arg)
{

    return NULL;
}

void init_service()
{
    Log::init("xkx");
}

int main()
{
    init_service();
    if (0 != pthread_create(&pthread_socket, NULL, pthread_socket_cb, NULL))
    {
        Log::e(TAG,"pthread_socket_cb call error");
        return -1;
    }

    if (0 != pthread_create(&pthread_kisql, NULL, pthread_kisql_cb, NULL))
    {
        Log::e(TAG,"pthread_socket_cb call error");
        return -1;
    }

    while(1){
        sleep(10);
    }
    closelog();
    return 0;
}
